$('document').ready(function(){	
	
	$( 'textarea#description' ).ckeditor();
    $.validator.addMethod("logoCheck", function (value, element) {
        return validateLogo();
    }, 'Please upload valid image');
	//validate form add
	$('#frmAdd').validate({
            errorClass      : 'error',
            errorElement	: 'span',
    		onfocusout		: false,
    		onkeyup			: false,
    		ignore			: 'input[type="text"]:hidden',
			rules:{
				name:{
					required:true,
					/*minlength:VL_NAME_MINLENGTH,
					maxlength:VL_NAME_MAXLENGTH*/
				},				
				sshort:{
					required:true,
					/*minlength:2,
					maxlength:2*/
				},
                description:{
                    required: true,
                },
                logo:{
                    logoCheck:true
                }
			},
			messages:{
				name:{
					required:name_required,
					/*minlength:VL_NAME_MINLENGTH,
					maxlength:VL_NAME_MAXLENGTH*/
				},				
				sshort:{
					required:short_required,
					/*minlength:2,
					maxlength:2*/
				},
                description:{
                    required: description_required,
                },
                logo:{}
			},
			errorPlacement: function(error, element) {
			       error.insertAfter(element); // change this to place error message elsewhere
			}			
	});
});

function validateLogo() {
    strLogoPath = $('#logo').val();
    strLink     = $('#link').val();
    if( strLogoPath.length > 0 ) {
        if(validateImage(strLogoPath)) {
            // image size 1MB
            if( validateImageSize(this,1) ){
                return true;
            }
        }
    }
    if(strLink.length > 0) {return true;}
    return false;
}